﻿// 物体基类

using SG;

public abstract class ObjectState : ObjectScene
{

    StateMachine m_StateMachine;
    public StateMachine StateMachine
    {
        get { return m_StateMachine; }
    }
    protected override void OnInitState()
    {
        if (m_StateMachine == null)
            m_StateMachine = gameObject.GetOrAddComponent<StateMachine>();

    }
    protected override bool OnUpdate()
    {
        StateMachine.DoUpdate();
        return true;
    }

    public void DoAddState(string name, StateBase state)
    {
        StateMachine.DoAddState(name, state);
    }
    public bool DoSetState(string strStateName, EventParam param = null, bool forceChange = false)
    {
        StateMachine.DoSetState(strStateName, param, forceChange);
        return true;
    }

    public virtual void DoSeneEvent(EventParam param)
    {
        StateMachine.DoSendEvent(param);
    }


    public virtual void DoStop(bool all = false)
    {

    }
}
